﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Pigg.Contracts;
using Pigg.Model;

namespace Pigg.Tests
{
    [TestClass]
    public class PageTests
    {
        private IPiggUow _piggUow;

        [TestInitialize]
        public void MyTestInitialize()
        {
            //this._pageRepository = new PageRepository();
        }

        [TestMethod]
        public void HomePageTest()
        {
            var home = _piggUow.ModelReader.GetPage();
            Assert.IsTrue(home.Title.Contains("home"));
        }

        [TestMethod]
        public void InternalPageTest()
        {
            const string route = "/article/something";
            var internalPage = _piggUow.ModelReader.GetPage(route);
            Assert.IsTrue(internalPage.Title.Contains("something"));
        }

        [TestMethod]
        public void CreateAPageBaseOnAContentType()
        {
            var myType = new ContentType
            {
                Created = DateTime.Now,
                NodeId = Guid.NewGuid().ToString().GetHashCode().ToString(CultureInfo.InvariantCulture),
                Route = new Route { Value = "home" },
                DataFields =
                    new List<DataField>
                    {
                        new DataField {Name = "Title", Value = string.Empty, DataType = DataType.Text},
                        new DataField {Name = "Body", Value = string.Empty, DataType = DataType.LongText}
                    }
            };
            
            const string route = "/article/something";
            var internalPage = _piggUow.ModelReader.GetPage(route);
            Assert.IsTrue(internalPage.Title.Contains("something"));
        }
    }
}
